package backend

import (
	"blog/models"
)

type AdminController struct {
	baseController
}

func (a *AdminController) Index() {
	a.display()
}

func (a *AdminController) Create() {
	var admin models.Admin
	a.Data["model"] = admin
	a.display()
}

func (a *AdminController) Edit() {
	id, _ := a.GetInt("id")
	admin, _ := models.GetById(models.AdminTable(), id)
	a.Data["model"] = admin
	a.display()
}

func (a *AdminController) ChangePassword() {
	id, _ := a.GetInt("id")
	a.Data["model"] = map[string]int{"Id": id}
	a.display()
}

func (a *AdminController) ChangeRole() {
	id, _ := a.GetInt("id")
	admin, _ := models.GetById(models.AdminTable(), id)
	a.Data["model"] = admin
	a.display()
}
